<?php
    session_start();
    
    include '../Include/functions.inc.php';
    include '../Include/translations.php';
    
    $string = "";
    
    $reload = $_POST['reload'];
    
    if($reload == 'true')
    {
        
        $messages = getAllMessages();
        
        //Parcours les messages et les affiche
        while($ligne = mysql_fetch_array($messages))
        {
            $string .= "<li><strong>$ligne[1]: </strong>$ligne[0]</li>";
        }
    }
    else{
        $message = $_POST['message'];
        $pseudo = $_POST['pseudo'];
        
         if(empty($message))
        {
            $string = $textes['espace_creatif_msg_oublier'][$_COOKIE['lang']];
        }
        elseif(empty($pseudo))
        {
            $string = $textes['espace_creatif_nom_oublier'][$_COOKIE['lang']];
        }
        else{
            saveMessageIntoDb($message, $pseudo);
            $string = $textes['espace_creatif_msg_envoye'][$_COOKIE['lang']];
        }
    }

    echo $string;
?>
